<?php

namespace Home\Controller;

use Think\Controller;

use Think\Log;

use Common\Controller\AuthController;

//import("Home.Library.QueryList.QueryList");

class WmController extends AuthController
{
    public function index()
    {
        // $this->show('<style type="text/css">*{ padding: 0; margin: 0; } div{ padding: 4px 48px;} body{ background: #fff; font-family: "微软雅黑"; color: #333;font-size:24px} h1{ font-size: 100px; font-weight: normal; margin-bottom: 12px; } p{ line-height: 1.8em; font-size: 36px } a,a:hover{color:blue;}</style><div style="padding: 24px 48px;"> <h1>:)</h1><p>欢迎使用 <b>ThinkPHP</b>！</p><br/>版本 V{$Think.version}</div><script type="text/javascript" src="http://ad.topthink.com/Public/static/client.js"></script><thinkad id="ad_55e75dfae343f5a1"></thinkad><script type="text/javascript" src="http://tajs.qq.com/stats?sId=9347272" charset="UTF-8"></script>','utf-8');
        echo "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />";
        $ordertime = "2015-12-01";
        $da = date("Y-m-d", strtotime($ordertime));
        echo gettype($da), "<br>";
        echo "today:", date('Y-m-d'), "<br>";
        echo "tomorrow:", date('Y-m-d h:i:s', strtotime('+1 day')), "<br>";

        $dif=-7;

        echo "-7 day:", date('Y-m-d h:i:s', strtotime($dif.' day')), "<br>";

        $para = array();
        $start = "2015-10-20";
        for ($i = 0; $i < 16; $i++) {
            $end = date('Y-m-d', strtotime('+6 day', strtotime($start)));

            $para[$start] = $end;
            $start = $end;
        }

//        var_dump($para);


        $url = 'http://www.baidu.com/s?ie=utf-8&f=3&rsv_bp=1&tn=monline_4_dg&wd=thinkphp%20%E6%8E%A7%E5%88%B6%E5%99%A8%20%E9%AD%94%E6%9C%AF%E6%96%B9%E6%B3%95&oq=php%20class%20%E5%AE%9E%E4%BE%8B&rsv_pq=b239d6380005fd51&rsv_t=b63faeB2qKraqeDQgp2BeMwTeWTIBU7FxQsWC%2F5vaNQWgUgp3n1OvsyslyTwy8oinMWJ&rsv_enter=1&inputT=22338&rsv_sug3=51&rsv_sug1=17&rsv_sug7=100&rsv_sug2=1&prefixsug=thinkphp%20%20%20%E6%8E%A7%E5%88%B6%E5%99%A8%20&rsp=7&rsv_sug4=24105';
//        print_r(parse_url($url));
//        echo parse_url($url, PHP_URL_PATH);

        $para=parse_url($url);

        var_dump($para);
        echo   "</br></br>";

        echo $para["query"];
        echo   "</br></br>";

        $start="2016-02-01";
        $end="2016-02-29";

        $start2 = date('Ymd',  strtotime('+1 month',strtotime($start)));
        $end2 = date('Ymd', strtotime('+1 month',strtotime($end)));

        echo $start2."     --".$end2;
        echo   "</br></br>";

//        $start2="20160201";
//        $end2="20160231";







    }

//    public function baidu()
//    {
//        require_once C('CUSTOM_LIBRARY') . '/httpful-2.phar';
//
//        // echo "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />";
//        // echo "百度外卖";
//
//        // echo __URL__
//
//        $this->display();
//    }

    public function baidudeal()
    {
        $baidu = new Baiduwm ();

        $today = date("Y-m-d");
        $range=Method::getthemonth($today);

        $baidu->login($range);

        $baidu->dealbdcsv();
    }

//    public function db()
//    {
//        $baidu = new Baiduwm ();
//
//        $baidu->db();
//    }

//    public function baidulogin()
//    {
//        $baidu = new Baiduwm ();
//        $today = date("Y-m-d",strtotime("-1 month"));
//        $range=Method::getthemonth($today);
//
//        $baidu->login($range);
//    }


    public function mtlogin()
    {
        $mt = new Meituanwm ();

        $mt->login();
    }




    public function mtdeal()
    {
        $mt = new Meituanwm ();

//        $mt->login();

        $mt->dealdata();
    }


    public function yzdeal()
    {
        $yz = new Youzanwm ();


        $yz->deal();
    }

//    public function mtdealdata()
//    {
//        $mt = new Meituanwm ();
//
//        $mt->dealdata();
//    }


//    public function upload()
//    {
//        $baidu = new Baiduwm ();
//
//        $baidu->upload();
//    }

    public function dingdan()
    {
        $dingdan = D("dingdan");

        $list = $dingdan->select();
        $count = Count($list);
        $page = new \Think\Page ($count, 40);


        $list = $dingdan->field('id,ddid,sid,name,sex,mobile,ltrim(rtrim(address)) as address,menu,ordertime,price,userpay,platpay,bosspay,income,status,invoice,shipping,memo')->order('ordertime desc')->limit($page->firstRow . ',' . $page->listRows)->select();

        // 设置分页参数
        $page->setConfig('first', '首页');
        $page->setConfig('prev', '上一页');
        $page->setConfig('next', '下一页');
        $page->setConfig('last', '末页');
        $page->setConfig('theme', ' 共%TOTAL_ROW% %HEADER% 共%TOTAL_PAGE%页
%FIRST%   %UP_PAGE% &nbsp;&nbsp;  %LINK_PAGE% &nbsp;&nbsp;   %DOWN_PAGE%   %END%');
        $show = $page->show();

        $this->assign('list', $list);
        $this->assign('page', $show);
        $this->display();
    }
}